import { ApiProperty, PartialType } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsBoolean, IsOptional } from "class-validator";

import { CreateCommentDto } from "./create-comment.dto";

export class UpdateCommentDto extends PartialType(CreateCommentDto) {
    @Transform(({ value }) => {
        if (value === "1" || value === "yes" || value === "true") return true;
        if (value === "0" || value === "no" || value === "false") return false;
        return value;
    }) // 在 QueryDto 中，参数是以 URL 中的查询参数携带，而 URL 都是字符串类型"false"/"true"，所以需要转换一下
    @IsOptional()
    @IsBoolean()
    @ApiProperty({
        example: "true",
        description: "是否审核通过",
        required: false
    })
    status: boolean;
}
